const path = require("path");
const webpack = require("webpack");
var hotMiddlewareScript = "webpack-hot-middleware/client";
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const BasicPlugin = require("./plugins/index");
module.exports = {
  target: "node",
  entry: {
    main: ["./src/main.js", hotMiddlewareScript],
  },
  mode: "development",
  output: {
    path: path.resolve(__dirname, "public"),
    filename: "js/[name].js",
    publicPath: "/",
  },
  externals: [nodeExternals()],
  resolve: {
    extensions: [".js"],
    // fallback: {
    //   fs: true,
    //   crypto: require.resolve("crypto-browserify"),
    // },
  },
  plugins: [
    // new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new NodePolyfillPlugin(),
    new BasicPlugin(),
  ],
};
